package router

import (
	"WebApplication/db"
	"WebApplication/service"
	"github.com/gin-gonic/gin"
)

func RegisterRouter(orderdatabase *db.OrderDatabase) *gin.Engine{
	wb := gin.Default()


	// orderdatabase 一个指针
	wb.Use(func(context *gin.Context) {
		context.Set("orderdatabase", orderdatabase)
	})


	// 新增订单
	wb.POST("/orders", service.CreateOrder)



	// 上传文件
	wb.POST("/orders/OrderNo/:OrderNo", service.UpLoadFileService)

	// 下载文件
	wb.GET("/orders/file/:filename", service.FileDownLoadService)

	// 模糊查找
	wb.GET("/orders/username/:name", service.NameCheckService)

	// 查找全部
	wb.GET("/orders", service.SelectAll)

	// 导出文件
	wb.GET("/sheet", service.ExportService)




	return wb
}